#pragma once

#include "scene.h"
#include <SDL.h>


class Game {
public:
    static Game& getInstance() {
        static Game instance;
        return instance;
    }
    ~Game();

    void init();
    void clean();

    void run();
    void changeScene(Scene* pscene);

    void handleEvent(SDL_Event event);
    void update(float deltaTime);
    void render();
    
    SDL_Renderer* getRenderer() { return prenderer_; }
    int getWindowWidth() { return window_width_; }
    int getWindowHeight() { return window_height_; }

private:    
    /// 单例模式
    Game();
    Game(const Game&) = delete;
    Game& operator=(const Game&) = delete;

private:
    bool is_running_ = true;
    Scene* pcurrent_scene_ = nullptr;
    SDL_Window* pwindow_ = nullptr;
    SDL_Renderer* prenderer_ = nullptr;

    int window_width_ = 800;
    int window_height_ = 600;

    int FPS_ = 60;
    Uint32 frameTime_ = 1000 / FPS_;
    float deltaTime_ = frameTime_ / 1000.0f;
};